package history

class CounterService {
    /**
     * 新增一筆counter name記錄，屆時可用筆數取得數量，並可用創建時間進行統計
    */
    def addCounts(String name) {
        if (name) {
            Counter counter = new Counter(name: name)
            counter.save()
        }
    }
    
    /**
     * 統計資料筆數取得數量
    */
    def getCounts(String name) {
        Counter.executeQuery("Select Count(name) From Counter Where name = ?", [name]).first()
    }
    
    def getAllCounts() {
        Counter.executeQuery("Select Count(*) From Counter").first()
    }

}
